package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhJude;
import com.ruoyi.xh.service.IXhJudeService;

/**
 * 判断Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "判断Controller",value = "判断Controller")
@RestController
@RequestMapping("/xh/jude")
public class XhJudeController extends BaseController {

    @Autowired
    private IXhJudeService xhJudeService;

    /**
     * 查询判断列表
     */
    @PreAuthorize("@ss.hasPermi('xh:jude:list')")
    @GetMapping("/list")
    @ApiOperation("查询判断列表")
    public TablePageDataInfo<XhJude> list(XhJude xhJude) {
        return TablePageDataInfo.success(xhJudeService.selectXhJudeList(xhJude));
    }

    /**
     * 获取判断详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:jude:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取判断详细信息")
    public CommentResult<XhJude> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhJudeService.selectXhJudeById(id));
    }

    /**
     * 新增判断
     */
    @PreAuthorize("@ss.hasPermi('xh:jude:add')")
    @Log(title = "判断", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增判断")
    public CommentResult<XhJude> add(@RequestBody XhJude xhJude) {
            xhJudeService.insertXhJude(xhJude);
        return CommentResult.success();
    }

    /**
     * 修改判断
     */
    @PreAuthorize("@ss.hasPermi('xh:jude:edit')")
    @Log(title = "判断", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改判断")
    public CommentResult<XhJude> edit(@RequestBody XhJude xhJude) {
            xhJudeService.updateXhJude(xhJude);
        return CommentResult.success();
    }

    /**
     * 删除判断
     */
    @PreAuthorize("@ss.hasPermi('xh:jude:remove')")
    @Log(title = "判断", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除判断")
    public CommentResult<XhJude> remove(@PathVariable Long[] ids) {
            xhJudeService.deleteXhJudeByIds(ids);
        return CommentResult.success();
    }
}
